class UserController < ApplicationController

  def new
    @user = User.new
    render :layout => false
  end  

  def create
    @user = User.new params[:user]
    if @user.save
      flash[:notice] = 'account create successful'
      redirect_to root_path 
    else
      render 'new', :layout => false
    end
  end

  def index
    @conditions = [" 1 = 1 "]
    if params
      if params[:name] and !params[:name].strip.empty?
        @conditions[0] += " AND name like ?"
        @conditions << "%#{params[:name].strip}%"
      end
    end
    @users = User.search(@conditions, params[:page], "id asc")
  end

  def show
    @user = User.find(params[:id])
    @idols = Follow.find_all_by_fensi_id @user.id
    @fensies = Follow.find_all_by_idol_id @user.id
    @weibos = Weibo.search(" user_id = " + @user.id.to_s, params[:page], "id desc")
    render :layout => false
  end

end
